package com.toby.demo.quickfixj.receiver;

import quickfix.Application;
import quickfix.DoNotSend;
import quickfix.FieldNotFound;
import quickfix.IncorrectDataFormat;
import quickfix.IncorrectTagValue;
import quickfix.Message;
import quickfix.RejectLogon;
import quickfix.SessionID;
import quickfix.UnsupportedMessageType;
import quickfix.fix44.MessageCracker;
import quickfix.fix44.NewOrderSingle;

public class FIXReceiver extends MessageCracker implements Application {

	@Override
	public void onMessage(NewOrderSingle order, SessionID sessionID) {
		System.out.println("Tobby Receiver onMessage.. message: " + order + ", sessionID: " + sessionID);
	}

	public void fromAdmin(Message message, SessionID sessionID)
			throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue,
			RejectLogon {
		System.out.println("Tobby Receiver fromAdmin.. message: " + message + ", SessionID: " + sessionID);
	}

	public void fromApp(Message message, SessionID sessionID)
			throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue,
			UnsupportedMessageType {
		System.out.println("Tobby Receiver fromApp.. sessionID: " + message);
		crack(message, sessionID); // calls onMessage(..,..)
	}

	public void onCreate(SessionID sessionID) {
		System.out.println("Tobby Receiver onCreate.. sessionID: " + sessionID);
	}

	public void onLogon(SessionID sessionID) {
		System.out.println("Tobby Receiver onLogon.. sessionID: " + sessionID);
	}

	public void onLogout(SessionID sessionID) {
		System.out.println("Tobby Receiver onLogout.. sessionID: " + sessionID);
	}

	public void toAdmin(Message message, SessionID sessionID) {
		System.out.println("Tobby Receiver toAdmin.. sessionID: " + sessionID);
	}

	public void toApp(Message message, SessionID sessionID) throws DoNotSend {
		System.out.println("Tobby Receiver toApp.. sessionID: " + sessionID);
	}

}
